package com.easy.controller;


import com.easy.bean.ManagerBean;
import com.easy.service.ManagerBeanService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("manager")
public class ManagerController {
    @Autowired
    ManagerBeanService managerBeanService;

    @PostMapping
    public Result add(@RequestBody ManagerBean managerBean){
        Object obj=managerBeanService.add(managerBean);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=managerBeanService.del(id);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody ManagerBean managerBean){
        Object obj=managerBeanService.edit(managerBean);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(ManagerBean managerBean){
        Object obj=managerBeanService.all(managerBean);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=managerBeanService.one(id);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, ManagerBean managerBean){
        managerBeanService.page(page,managerBean);
        return Result.success(page);
    }
}
